﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Wedn.Core.Utility;


namespace Wedn.Core.Entity
{
    /// <summary>
    /// 用户实体拓展模型类
    /// </summary>
    public class User
    {
        private string link;
        /// <summary>
        /// 用户个人页链接
        /// </summary>
        public string Link
        {
            get
            {
                if (link == null)
                {
                    //    string siteurl = Config.SiteUrl.TrimEnd('/');
                    //    string permalink = Setting.Permalink;
                    //    if (!string.IsNullOrEmpty(permalink))
                    //    {
                    //        link = Regex.Replace(permalink, "{siteurl}", siteurl);
                    //        link = Regex.Replace(url, "{dir}", "post");
                    //        link = Regex.Replace(url, "{alias}", this.login);
                    //        link = Regex.Replace(url, "{slug}", this.login);
                    //        link = Regex.Replace(url, "{id}", this.Id.ToString());
                    //    }
                    //    else
                    //    {
                    //        link = string.Format("{0}/?auther={1}", siteurl, this.Id);
                    //    }
                    link = string.Format("<a href=\"{0}\">{1}</a>", this.Url, this.nickName);
                }
                return link;
            }
        }

        #region 所有字段
        private int id;
        private string login;
        private string nickName;
        private string password;
        private string email;
        private string url;
        private DateTime regDate = DateTime.Now;
        //private string avatar = "avatar/avatar_default.jpg";
        private int status;
        private int role;
        #endregion

        #region 对外公共属性
        /// <summary>
        /// 主键(自增长)字段
        /// </summary>
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        /// <summary>
        /// 用户登录名字段
        /// </summary>
        public string Login
        {
            get { return login; }
            set { login = value; }
        }
        /// <summary>
        /// 用户昵称字段
        /// </summary>
        public string NickName
        {
            get { return nickName; }
            set { nickName = value; }
        }
        /// <summary>
        /// 用户密码字段
        /// </summary>
        public string Password
        {
            get { return password; }
            set { password = value; }
        }
        /// <summary>
        /// 用户电子邮箱地址字段
        /// </summary>
        public string Email
        {
            get { return email; }
            set { email = value; }
        }
        /// <summary>
        /// 用户个人主页链接字段
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; }
        }
        /// <summary>
        /// 用户注册时间字段
        /// </summary>
        public DateTime RegDate
        {
            get { return regDate; }
            set { regDate = value; }
        }
        ///// <summary>
        ///// 用户照片(头像)字段
        ///// </summary>
        //public string Avatar
        //{
        //    get { return avatar; }
        //    set { avatar = value; }
        //}
        /// <summary>
        /// 用户当前状态字段(0:正常, 1:待审核验证)
        /// </summary>
        public int Status
        {
            get { return status; }
            set { status = value; }
        }
        /// <summary>
        /// 用户所属角色(0:管理员,1:撰写人,2:订阅者)字段
        /// </summary>
        public int Role
        {
            get { return role; }
            set { role = value; }
        }
        #endregion

        #region 构造函数
        public User() { }
        ///// <summary>
        ///// 用户信息表模型类构造函数
        ///// </summary>
        ///// <param name="id">用户表ID</param>
        ///// <param name="loginName">用户登录名</param>
        ///// <param name="nickName">用户昵称</param>
        ///// <param name="password">用户密码</param>
        ///// <param name="email">用户电子邮箱地址</param>
        ///// <param name="url">用户个人主页地址</param>
        ///// <param name="regDate">用户注册时间</param>
        ///// <param name="avatar">用户头像</param>
        ///// <param name="status">用户当前状态(0:正常, 1:待审核验证)</param>
        ///// <param name="role">用户权限(0:管理员,1:撰写人,2:订阅者)</param>
        //public User(int id, string loginName, string nickName, string password, string email, string url, DateTime regDate, string avatar, int status, int role)
        //{
        //    this.id = id;
        //    this.login = loginName;
        //    this.nickName = nickName;
        //    this.password = password;
        //    this.email = email;
        //    this.url = url;
        //    this.regDate = regDate;
        //    this.avatar = avatar;
        //    this.status = status;
        //    this.role = role;
        //}
        #endregion
    }
}
